package org.vestbjergbyggecenter.Model;

public class Product {
	private int id;
	private String name;
	private Category category;
	private double originalPrice;
	private double discountPrice;
	private int quantity;
	private String location;
	
	public Product(int newID, String newName, Category newCategory, double newOriginalPrice, int newQuantity,
			String newLocation)
	{
		this.id=newID;
		this.name=newName;
		this.category=newCategory;
		this.originalPrice=newOriginalPrice;		
		this.quantity=newQuantity;
		this.location=newLocation;
			
		this.discountPrice=newOriginalPrice;
	}
	
	
	public void setId(int id) {
		this.id = id;
	}
	
	public void setOriginalPrice(double newOriginalPrice)
	{
	 this.originalPrice = newOriginalPrice;
	 this.discountPrice=newOriginalPrice;
	}

	public void setName(String newName)
	{
	 this.name = newName;
	}
	public void setCategory(Category newCategory)
	{
	 this.category = newCategory;
	}
	public void setQuantity(int quantity) {
		this.quantity = quantity;
	}
	public void setLocation(String newLocation)
	{
	 this.location = newLocation;
	}
	public int getId() {
		return id;
	}
	public double getOriginalPrice()
	{
	 return originalPrice;
	}
	
	//method to set the discountPrice
	public void setDiscountPrice(double discountPrice)
	{
		this.discountPrice=discountPrice;
	}
	
	//method get the discount price
	public double getDiscontPrice()
	{
		return discountPrice;
	}
	
	//set the price of the product after the product discount is made and return that price
	public double getProductDiscountPrice()
	{
		double discountProduct=0; //this will be the price of the product after the product discount is reduced from the original price
		discountProduct=originalPrice-originalPrice*(category.getDiscount())/100;
		if(discountProduct>=0.8*originalPrice)
		{
			setDiscountPrice(discountProduct);
			return getDiscontPrice();
		}
		else
		{
			return originalPrice;
		}	
	}
	
	public String getName()
	{
	 return name;
	}
	public Category getCategoty()
	{
	 return category;
	}
	public int getQuantity()
	{
	 return quantity;
	}
	public String location()
	{
	 return location;
	}
	
	public void decreaseQuantity(int subQuantity)
	{
		if(subQuantity>quantity)
		{
			System.out.println("You do not have enough product");
		}
		else{
			quantity-=subQuantity;
			if(quantity<10)
			{
				System.out.println("Order more of the product");
			}
			else{
				System.out.println("Available products left in stock" + quantity);
			}
		}
	}
	
	public void print()
	{
		System.out.println("Product information!");
		System.out.println("ID: " + getId());
		System.out.println("Name: " + getName());
		System.out.println("In stock: " + getQuantity());
		System.out.println("Price: " + getDiscontPrice());
	}
}
